# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# Generated by Django 4.2.4 on 2023-10-09 20:28

import django.contrib.postgres.fields
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("trackingserver_auth", "0001_initial"),
        ("trackingserver_template", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="DAGRun",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("run_start_time", models.DateTimeField(null=True)),
                ("run_end_time", models.DateTimeField(null=True)),
                (
                    "run_status",
                    models.CharField(
                        choices=[
                            ("RUNNING", "RUNNING"),
                            ("SUCCESS", "SUCCESS"),
                            ("FAILURE", "FAILURE"),
                            ("UNINITIALIZED", "UNINITIALIZED"),
                        ],
                        max_length=255,
                    ),
                ),
                ("tags", models.JSONField()),
                ("inputs", models.JSONField()),
                (
                    "outputs",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=models.CharField(), size=None
                    ),
                ),
                (
                    "dag_template",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="trackingserver_template.dagtemplate",
                    ),
                ),
                (
                    "launched_by",
                    models.ForeignKey(
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="trackingserver_auth.user",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="NodeRunAttribute",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=63)),
                ("type", models.CharField(max_length=63)),
                ("schema_version", models.IntegerField()),
                ("value", models.JSONField()),
                ("node_name", models.CharField(db_index=True, max_length=255)),
                (
                    "attribute_role",
                    models.CharField(
                        choices=[
                            ("result_summary", "result_summary"),
                            ("error", "error"),
                            ("resource_utilization", "resource_utilization"),
                            ("artifact_link", "artifact_link"),
                            ("logs", "logs"),
                        ]
                    ),
                ),
                (
                    "dag_run",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="trackingserver_run_tracking.dagrun",
                    ),
                ),
            ],
            options={
                "unique_together": {("name", "node_name", "dag_run")},
            },
        ),
        migrations.CreateModel(
            name="NodeRun",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("node_template_name", models.CharField(db_index=True, max_length=255)),
                ("node_name", models.CharField()),
                (
                    "realized_dependencies",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=models.CharField(), null=True, size=None
                    ),
                ),
                ("start_time", models.DateTimeField(null=True)),
                ("end_time", models.DateTimeField(null=True)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("RUNNING", "RUNNING"),
                            ("SUCCESS", "SUCCESS"),
                            ("FAILURE", "FAILURE"),
                            ("UNINITIALIZED", "UNINITIALIZED"),
                        ],
                        max_length=15,
                    ),
                ),
                (
                    "dag_run",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="trackingserver_run_tracking.dagrun",
                    ),
                ),
            ],
            options={
                "unique_together": {("dag_run", "node_name")},
            },
        ),
    ]
